import 'package:flutter/material.dart';
import './../bean/ItemInfo.dart';

// 定义一个回调接口
typedef OnItemClickListener = void Function(int position);

class HomeListItem extends StatelessWidget {
  int position;
  ItemInfo iteminfo;
  OnItemClickListener listener;

  HomeListItem(this.position, this.iteminfo, this.listener);

  @override
  Widget build(BuildContext context) {
    var widget = Column(
      children: <Widget>[
        Container(
          child: Column(
            children: <Widget>[
              Row(
                children: <Widget>[
                  Text(
                    iteminfo.title,
                    style: TextStyle(
                      fontSize: 15.0,
                      color: Color(0xff999999),
                    ),
                  )
                ],
              ),
            ],
            mainAxisAlignment: MainAxisAlignment.center,
          ),
          height: 50.0,
          color: Color.fromARGB(255, 241, 241, 241),
          padding: EdgeInsets.only(left: 20.0),
        ),
        //用Container设置分割线
        Container(
          height: 1.0,
          color: Color.fromARGB(255, 230, 230, 230),
        )
        //分割线
//      Divider()
      ],
    );
    //InkWell点击的时候有水波纹效果
    return InkWell(onTap: () => listener(position), child: widget);
  }
}
